#!/bin/csh -f


set RUNDIR  = ./
set LIBDIR  = ./include
set CODEDIR = ./code
set STIMDIR = ./stim
set TOPDIR  = ./top
set SIMDIR  = ./sim
set HDLPATH = ./hdl.var
set CDSPATH = ./cds.lib


if (-e work) then
\rm -r work
endif
mkdir work


#CODE
ncvlog  -cdslib $CDSPATH -hdlvar $HDLPATH -MESSAGES -NOCOPYRIGHT -LINEDEBUG   $CODEDIR/N25Qxxx.v
if ( $status != 0 ) exit 3


#STIM
ncvlog  -cdslib $CDSPATH -hdlvar $HDLPATH -MESSAGES -NOCOPYRIGHT -LINEDEBUG  $STIMDIR/read.v
if ( $status != 0 ) exit 4


#TOP
ncvlog  -cdslib $CDSPATH -hdlvar $HDLPATH -MESSAGES -NOCOPYRIGHT -LINEDEBUG  $TOPDIR/Testbench.v
if ( $status != 0 ) exit 5
ncvlog  -cdslib $CDSPATH -hdlvar $HDLPATH -MESSAGES -NOCOPYRIGHT -LINEDEBUG  $TOPDIR/StimTasks.v
if ( $status != 0 ) exit 5
ncvlog  -cdslib $CDSPATH -hdlvar $HDLPATH -MESSAGES -NOCOPYRIGHT -LINEDEBUG  $TOPDIR/ClockGenerator.v
if ( $status != 0 ) exit 5


cd $SIMDIR


# Elaborate
ncelab -cdslib ../$CDSPATH -hdlvar ../$HDLPATH -mess -NOWARN CUDEFB work.Testbench -access +r
if ( $status != 0 ) exit 6


# Simulate
#ncsim -cdslib ../$CDSPATH -hdlvar ../$HDLPATH work.Testbench -gui  $1 &
ncsim -cdslib ../$CDSPATH -hdlvar ../$HDLPATH work.Testbench  $1 &
if ( $status != 0 ) exit 7


